package com.groovy.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project

class ApplicationPlugin implements Plugin<Project> {


    @Override
    void apply(Project project) {

        //创建扩展属性
        def appExt = project.extensions.create("appExtBoot", ApplicationExtension)


        //创建Task任务方法1、
        project.tasks.create('applyTasks', ApplicationTask)

        //创建Task任务方法2
        project.task('applyTask') {
            //设置taks编译组
            group = "groovy-kit"
            description = "starting applyTask.."

            doLast {
                def token = project.extensions.appExtBoot.token
                println("applyTask extensions token=${token}")
                println("applyTask appExt token=${appExt.token}")
            }
        }

        //注册Gradle 配置阶段完成以后的回调
        project.afterEvaluate {
            def token = project.extensions.appExtBoot.token
            println("afterEvaluate token=${token}")
        }


    }
}


class ApplicationExtension {
    String token
    String appKey
    String hostUrl
}